package gunfire.events;

import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.events.AbstractImageEvent;
import com.megacrit.cardcrawl.localization.EventStrings;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import gunfire.GunfireMod;

import static gunfire.GunfireMod.makeEventPath;

public class RedChestEvent1 extends AbstractImageEvent {
    public static final String ID = GunfireMod.makeID("RedChestEvent1");
    private static final EventStrings eventStrings = CardCrawlGame.languagePack.getEventString(ID);
    private static final String NAME = eventStrings.NAME;
    private static final String[] DESCRIPTIONS = eventStrings.DESCRIPTIONS;
    private static final String[] OPTIONS = eventStrings.OPTIONS;
    public static final String IMG = makeEventPath("RedChest.png");
    private int screenNum;
    private int damage;

    public RedChestEvent1() {
        super(NAME, DESCRIPTIONS[0], IMG);
        this.screenNum = 0;
        this.damage = (int)(AbstractDungeon.player.maxHealth * 0.2F);
        this.imageEventText.setDialogOption(OPTIONS[0] + damage + OPTIONS[1]);
        this.imageEventText.setDialogOption(OPTIONS[2] + damage + OPTIONS[3]);
        this.imageEventText.setDialogOption(OPTIONS[4]);
    }

    @Override
    protected void buttonEffect(int i) {
        if (this.screenNum == 0) {
            switch (i) {
                case 0:
                    AbstractDungeon.player.damage(new DamageInfo(null, this.damage, DamageInfo.DamageType.HP_LOSS));
                    AbstractDungeon.player.increaseMaxHp(8, true);
                    break;
                case 1:
                    AbstractDungeon.player.damage(new DamageInfo(null, this.damage, DamageInfo.DamageType.HP_LOSS));
                    AbstractRelic r = AbstractDungeon.returnRandomScreenlessRelic(AbstractRelic.RelicTier.COMMON);
                    AbstractDungeon.getCurrRoom().spawnRelicAndObtain((float)(Settings.WIDTH / 2), (float)(Settings.HEIGHT / 2), r);
                    break;
                case 2:
                    this.openMap();
                    break;
            }
            this.imageEventText.clearAllDialogs();
            this.imageEventText.setDialogOption(OPTIONS[4]);
            this.screenNum++;
        } else {
            this.openMap();
        }
    }
}
